package com.hhs.storage.bean;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.hhs.storage.util.SysUtil;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author hhs
 * @since 2018-09-29
 */
@Data
@ToString
@TableName("base_user")
public class BaseUser extends Model<BaseUser> {

    private static final long serialVersionUID = 1L;

    @TableId("id_")
    private String id;
    @TableField("account_")
    private String account;
    @TableField("name_")
    private String name;
    @TableField("number_")
    private String number;
    @TableField("password_")
    @JSONField(serialize = false)//密码禁止json转换
    private String password;
    @TableField("email_")
    private String email;
    @TableField("remark_")
    private String remark;
    @TableField("create_time_")
    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @TableField("point_")
    private Integer point;
    @TableField("photo_url_")
    private String photoUrl;
    @TableField("birthday_")
    @JSONField(format="yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
    @TableField("status_")
    private Boolean status;
    @TableField("gender_")
    private String gender;
    //车队类型
    @TableField("car_fleet_type")
    private Integer carFleetType;
    //查询排序字段，值越小排序越高
    @TableField("order_num")
    private Integer orderNum;
    //父级id
    @TableField("p_id_")
    private String pId;
    @TableField("school_id_")
    private String schoolId;

    @TableField(exist = false)
    String roleNames;
    @TableField(exist = false)
    String departNames;
    @TableField(exist = false)
    BaseDepartment department;
    @TableField(exist = false)
    List<BaseDepartment> departmentList;
    @TableField(exist = false) //用户所有计划列表
    private List<PersonalPlan> personalPlanList=new ArrayList<>();
    @TableField(exist = false)
    private List<CarFleet> carFleetList;//管理的车队列表
    @TableField(exist = false)
    private String attendanceRace;//出勤率用于计划管理-监督管理
    @TableField(exist = false)
    private String absenceRace;//缺勤率用于计划管理-监督管理
    @TableField(exist = false)
    private String attendanceDays;//出勤天数用于计划管理-监督管理
    @TableField(exist = false)
    private String absenceDays;   //缺勤天数用于计划管理-监督管理

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    public String getCarFleetTypeName(){ //获取车队类型
        if (this.carFleetType==null){
            return null;
        }
        return SysUtil.CAR_FLEET_TYPE_MAP.get(this.carFleetType);
    }
}
